package day19;

import java.util.Arrays;

public class TestNumber {
    public static void main(String[] args) {
        int nums[]={1,5,7,12,9,3};
        for (int i=0;i<nums.length;i++){
            for (int j=0;j< nums.length-i-1;j++){
                if (nums[j]<nums[j+1]){
                    nums[j]=nums[j]^nums[j+1];
                    nums[j+1]=nums[j]^nums[j+1];
                    nums[j]=nums[j]^nums[j+1];
                }
            }
        }
        System.out.println("排序后的数组："+ Arrays.toString(nums));
        System.out.println("第二大的数值："+nums[1]);
    }
}

class Number{
    public static void main(String[] args) {
        int nums[]={1,5,7,12,9,3};
        int max=nums[0];
        int second=Integer.MIN_VALUE; //整形的最小值
        for (int i=0;i<nums.length;i++){
            if (max<nums[i]){  //找到最大值
                second=max;
                max=nums[i];
            }else if (second<nums[i]){  //找到第二大值
                second=nums[i];
            }
        }
        System.out.println("第二大的值为："+second);
    }
}